package javase.javase01.exercise07;

import java.io.*;

/**
 * @author: Gan
 * @date 2021/4/19 0019 13:53
 * @description: 利用字符流去读取一个文本文件，每次读取一行，并将这行数据逆序，写入新的文本文件当中
 **/
public class Work1 {
    public static void main(String[] args) throws IOException {
        //创建输入输出流
        FileReader fr = new FileReader("a.txt");
        BufferedReader reader = new BufferedReader(fr);
        BufferedWriter writer = new BufferedWriter(new FileWriter("b.txt"));
        String str;
        while ((str = reader.readLine()) != null) {
            char[] chars = str.toCharArray();
            for (int i = str.length()-1; i >= 0; i--) {
                writer.write(chars[i]);
            }
            writer.newLine();
            writer.flush();
        }
        reader.close();
        writer.close();
    }
}
